home *** CD-ROM | disk | FTP | other *** search
- package asp.wizard;
-
- import asp.wizard.util.UiUtil;
- import com.sun.java.swing.BorderFactory;
- import com.sun.java.swing.JDialog;
- import com.sun.java.swing.JLabel;
- import com.sun.java.swing.JProgressBar;
- import com.sun.java.swing.UIManager;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.GridBagConstraints;
- import java.awt.GridBagLayout;
-
- public class ProgressStatus extends JDialog {
- public static final int PROGRESSBAR_MIN = 0;
- public static final int PROGRESSBAR_MAX = 100;
- private static final int WIDTH = 400;
- private static final int HEIGHT = 100;
- private static ProgressStatus _instance;
- private JLabel _txfStatus;
- private JProgressBar _pgbProgress;
-
- public static ProgressStatus getInstance() {
- if (_instance == null) {
- _instance = new ProgressStatus();
- }
-
- return _instance;
- }
-
- private ProgressStatus() {
- this.initComponents();
- this.initLayout();
- }
-
- public void dispose() {
- if (this == _instance) {
- _instance = null;
- }
-
- super.dispose();
- }
-
- private void initComponents() {
- this._txfStatus = new JLabel();
- this._txfStatus.setBorder(BorderFactory.createEmptyBorder());
- this._txfStatus.setBackground(UIManager.getColor("Control"));
- this._pgbProgress = new JProgressBar();
- this._pgbProgress.setMinimum(0);
- this._pgbProgress.setMaximum(100);
- this._pgbProgress.setValue(0);
- }
-
- private void initLayout() {
- Container c = ((JDialog)this).getContentPane();
- GridBagLayout gbl = new GridBagLayout();
- GridBagConstraints gbc = new GridBagConstraints();
- c.setLayout(gbl);
- UiUtil.addComponent(c, this._pgbProgress, gbl, gbc, 0, 0, 1, 1, (double)1.0F, (double)0.0F, 17, 2, 20, 5, 0, 5);
- UiUtil.addComponent(c, this._txfStatus, gbl, gbc, 0, 1, 1, 1, (double)1.0F, (double)1.0F, 18, 2, 10, 5, 10, 5);
- ((Component)this).setSize(400, 100);
- UiUtil.centerComponentInScreen(this);
- }
-
- public void reset() {
- this._txfStatus.setText("");
- this._pgbProgress.setValue(0);
- }
-
- public void setValue(int value) {
- if (value < 0) {
- value = 0;
- } else if (value >= 100) {
- value = 100;
- }
-
- this._pgbProgress.setValue(value);
- Thread.yield();
- }
-
- public void setText(String newText) {
- newText = newText == null ? "" : newText;
- this._txfStatus.setText(newText);
- this._txfStatus.invalidate();
- this._txfStatus.getParent().validate();
- Thread.yield();
- }
- }
-